/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       material_icons.h

	$Header: /game/material_icons.h $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "material_icons.h"

#include <vector>
#include "bitmap_layer_cache.h"

char const*          k_material_keyword[k_material_count] = 
{ "gold", "wood", "ore", "crystal", "sulfur", "mercury", "gems" };

t_bitmap_group_cache g_material_icons( "materials" );

namespace {
	class t_material_cache
	{
	public:
		t_material_cache();

		t_bitmap_layer_cache const& operator[]( t_material material ) const;
	protected:
		std::vector<t_bitmap_layer_cache> m_caches;
	};

	inline t_bitmap_layer_cache const& t_material_cache::operator []( t_material material ) const
	{
		return m_caches[material];
	}
};

t_material_cache::t_material_cache()
{
	int i;

	for (i = 0; i < k_material_count; i++)
		m_caches.push_back( t_bitmap_layer_cache( g_material_icons, k_material_keyword[i] ) );
}

t_bitmap_layer_ptr get_material_icon( t_material material )
{
	static t_material_cache cache;

	return cache[material].get();
}
